package ipebg.mzk.provider.system.service.impl;

import ipebg.mzk.facade.entity.LogMongo;
import ipebg.mzk.facade.system.service.LogService;
import ipebg.mzk.provider.system.dao.ILogDao;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;

@Service("logServiceImpl")
public class LogServiceImpl implements LogService{
	private static Log log = LogFactory.getLog(LogServiceImpl.class);
	@Resource(name="logDao")
	ILogDao logDao;
	
	@Override
	public void save(LogMongo logInstance) throws Exception {
		logDao.save(logInstance);		
	}

	@Override
	public void deleteByQuery(String key,Object value) throws Exception {
		Query query =new Query();
		query.addCriteria(Criteria.where(key).is(value));
		logDao.deleteByQuery(query);
		
	}

	@Override
	public Long getCount(String key, Object value) throws Exception {
		Query query =new Query();
		query.addCriteria(Criteria.where(key).is(value));
		return logDao.getCount(query);
	}

	@Override
	public List<LogMongo> getPage(Query query, int start, int size) throws Exception {
		return logDao.getPage(query, start, size);
	}

	@Override
	public void updateMulti(Query query, Update update) throws Exception {
		logDao.updateMulti(query, update);
	}

	@Override
	public void updateFirst(Query query, Update update) throws Exception {
		logDao.updateFirst(query, update);
	}

}
